using OpenAI.ObjectModels.RequestModels;

namespace MultiAgentsClient.ChatDataStructures;

public partial record ChatProjectDisp(int Id, string ChatProjectName, string ProjectSettings, bool Expanded, List<ChatRoomDisp> ChatRoomList)
{
    public ChatProjectDisp ToggleExpanded()
    {
        return this with
        {
            Expanded = !Expanded
        };
    }

    public ChatProjectDisp UpdateSelectedChatRoom(int selectedChatRoomId)
    {
        var updatedChatRoomList = new List<ChatRoomDisp>();
        foreach (var chatRoomDisp in ChatRoomList)
        {
            updatedChatRoomList.Add(chatRoomDisp.ToggleSelected(chatRoomDisp.Id == selectedChatRoomId));
        }

        return this with
        {
            ChatRoomList = updatedChatRoomList
        };
    }

    public ChatProjectDisp RenameChatRoom(int chatRoomId, string chatRoomName)
    {
        var updatedChatRoomList = new List<ChatRoomDisp>();
        foreach (var chatRoomDisp in ChatRoomList)
        {
            if (chatRoomDisp.Id == chatRoomId)
            {
                updatedChatRoomList.Add(chatRoomDisp.Rename(chatRoomName));
            }
            else
            {
                updatedChatRoomList.Add(chatRoomDisp);
            }
        }

        return this with
        {
            ChatRoomList = updatedChatRoomList
        };
    }
}

public partial record ChatRoomDisp(int Id, string ChatRoomName, bool IsSelected, List<ChatMessageDisp> Messages)
{
    public ChatRoomDisp ToggleSelected(bool isSelected)
    {
        return this with
        {
            IsSelected = isSelected
        };
    }
    public ChatRoomDisp Rename(string newName)
    {
        return this with
        {
            ChatRoomName = newName
        };
    }

}
public partial record ChatMessageDisp(int Id, string Content, string MsgOwner, string? Author, List<int>? HistoryMessagesIdList, int SenderId, DateTime Time, bool MsgStreamFinished, List<ToolCall>? ToolCalls, bool ToolCallsRequireApproval) { }
public partial record WorkflowNotificationDisp(int Id, string Content, string WorkflowName, string CountDownStr) { }
public partial record ToolCallDisp(int Id, string Name, bool IsCheck) { }
public partial record PresetMessageDisp(int Id, string Role, string Message) { }
